package com.bcxj.routeplan.controller;

import com.bcxj.internalcommon.dto.*;
import com.bcxj.internalcommon.response.ResponseResult;
import com.bcxj.routeplan.service.RouteplanService;
import org.apache.coyote.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: RouteplanController
 * Package: com.bcxj.routeplan.controller
 * Description:
 *
 * @Author BCXJ
 * @Create 2025/2/13 09:22
 * @Version 1.0
 * @Since 1.0
 */
@RestController
@RequestMapping("direction")
public class RouteplanController {

    @Autowired
    private RouteplanService routeplanService;


    /**
     * 推荐服务
     * @param directionRecommendDTO
     * @return
     */
    @PostMapping("/recommend")
    public ResponseResult recommend(@RequestBody DirectionRecommendDTO directionRecommendDTO) {
        Long userId = directionRecommendDTO.getUserId();
        String depLongitude = directionRecommendDTO.getDepLongitude();
        String depLatitude = directionRecommendDTO.getDepLatitude();
        String destLongitude = directionRecommendDTO.getDestLongitude();
        String destLatitude = directionRecommendDTO.getDestLatitude();
        return routeplanService.recommend(userId, depLongitude, depLatitude, destLongitude, destLatitude);
    }


    /**
     * 调用三方接口获取 步行的路径规划
     * @param directionWalkDTO
     * @return
     */
    @GetMapping("walking")
    public ResponseResult walk(DirectionWalkDTO directionWalkDTO){
        String depLongitude = directionWalkDTO.getDepLongitude();
        String depLatitude = directionWalkDTO.getDepLatitude();
        String destLongitude = directionWalkDTO.getDestLongitude();
        String destLatitude = directionWalkDTO.getDestLatitude();
        return routeplanService.walk(depLongitude, depLatitude, destLongitude, destLatitude);
    }


    /**
     * 调用第三方接口获取驾车的路径规划
     * @param directionDriveDTO
     * @return
     */
    @GetMapping("driving")
    public ResponseResult drivering(DirectionDriveDTO directionDriveDTO){
        String depLongitude = directionDriveDTO.getDepLongitude();
        String depLatitude = directionDriveDTO.getDepLatitude();
        String destLongitude = directionDriveDTO.getDestLongitude();
        String destLatitude = directionDriveDTO.getDestLatitude();
        String strategy = directionDriveDTO.getStrategy();
        return routeplanService.driving(depLongitude, depLatitude, destLongitude, destLatitude, strategy);
    }


    /**
     *  调用第三方接口实现公共交通的路径规划信息
     * @param directionTransitDTO
     * @return
     */
    @GetMapping("public-transit")
    public ResponseResult publicTransport(DirectionTransitDTO directionTransitDTO) {
        String depLongitude = directionTransitDTO.getDepLongitude();
        String depLatitude = directionTransitDTO.getDepLatitude();
        String destLongitude = directionTransitDTO.getDestLongitude();
        String destLatitude = directionTransitDTO.getDestLatitude();
        String depCity = directionTransitDTO.getDepCity();
        String destCity = directionTransitDTO.getDestCity();
        String strategy = directionTransitDTO.getStrategy();
        return routeplanService.transit(depLongitude, depLatitude, destLongitude, destLatitude, depCity, destCity, strategy);
    }


    /**
     * 骑行的数据路径规划
     * @param directionBicycleDTO
     * @return
     */
    @GetMapping("bicycle")
    public ResponseResult bicycle(DirectionBicycleDTO directionBicycleDTO) {
        String depLongitude = directionBicycleDTO.getDepLongitude();
        String depLatitude = directionBicycleDTO.getDepLatitude();
        String destLongitude = directionBicycleDTO.getDestLongitude();
        String destLatitude = directionBicycleDTO.getDestLatitude();
        return routeplanService.bicycle(depLongitude, depLatitude, destLongitude, destLatitude);
    }

}
